var query = MemberTable.Where(x=>x.sex.Equals(Sex)) if (members != null) query = query.Where(x=>members.Contains(x.membercode)) //use your query query.ToList();
var query = mainQuery.Where(a => a.TableId.Id == 5);